//
//  @ Project : Galaxy Star Trading System
//  @ File Name : QuoteManager.h
//  @ Date : 2014/9/5
//  @ Author :
//
//


#if !defined(_CQUOTEMANAGER_H)
#define _CQUOTEMANAGER_H

#ifndef _RUN_COMMANDLINE_MODE

#ifdef _RUN_WINDOWS_
	#include "MsgpackDepthMarketData.h"
#endif

struct SHistoricalData;
class CRealDataFileOperate;
namespace GSTrader
{
	namespace QuoteService
	{
		class QUOTE_SERVICE_API CRealQuoteManager
		{
		public:
			CRealQuoteManager(PVOID lpDataManager);
			virtual ~CRealQuoteManager();

			bool LoadOpenCloseConfigFile();

			void LoadMarketData();
			void SaveMarketData();

			void OnMarketData(CDepthMarketData* pMarketData);
			void OnInstrument(CMsg* pMsg);

			CDepthMarketData* GetMarketDataById(int nInstrumentId);
			CDepthMarketData* GetMarketDataBySymbol(CInstrumentLongCode& code);
			CDepthMarketData* GetMarketDataBySymbol(string strInstrumentId, string strExchangeId = "");
			COpenCloseTime* GetOpenCloseTimeBySymbol(string strInstrumentId);
			COpenCloseTime* GetOpenCloseTimeByType(string strType);
			string GetExchageIdBySymbol(string strInstrumentId);

			bool GetMin1FromRealData(string strCode, vector<SHistoricalData>& vHisData);
			bool GetTickData(string strCode, vector<SGSTickData>& vTickData);
			bool UpdateTickData(string strExchangeId, string strCode, vector<SGSTickData>& vTickData);

			bool GetHistoricalData(CBarSeriesIndex& BarSeriesIndex, vector<SHistoricalData>& vHisData);
			bool GetReportData(int nStart, int nEnd, int nSortId, int nMarketId, int nKindId, vector<CDepthMarketData>& vMarketData);
	
		private:
			PVOID m_pDataManager;
		};
	}
}

#endif
#endif //_CQUOTEMANAGER_H